package supertuxwar.powerup;

import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

import supertuxwar.TileEnvironment;

public class Pistol extends Powerup {
	
	private Image image;
	
	public Pistol(float x, float y) throws SlickException {
		super(x, y);
		image = new Image("res/pistol.png");
	}
	
	public String getName() {
		return "Pistol";
	}

	@Override
	public void doAction() throws SlickException {
		
		// Action
		// TODO: 判断actor的方向
		Bullet bullet = null;
		if(actor.facingRight()) {
			bullet = new Bullet(actor.getX()+16, actor.getY(), .01f, this);
			bullet.setVelocity(100f, 0);
		} else {
			bullet = new Bullet(actor.getX()-16, actor.getY(), .01f, this);
			bullet.setVelocity(-100f, 0);
		}
		
		if(bullet != null) {
			TileEnvironment.getInstance().addEntity(bullet);
		}
	}
	
	
	@Override
	public Image getImage() {
		return image;
	}

}
